<?php echo $header; ?><?php echo $column_left; ?>
<div id="content"><?php echo $content_top; ?>
  <div class="breadcrumb">
    <?php foreach ($breadcrumbs as $breadcrumb) { ?>
    <?php echo $breadcrumb['separator']; ?><a href="<?php echo $breadcrumb['href']; ?>"><?php echo $breadcrumb['text']; ?></a>
    <?php } ?>
  </div>
  <h1><?php echo $heading_title; ?></h1>
  <table class="list">
    <thead>
      <tr>
        <td class="left" colspan="2"><?php echo $text_order_detail; ?></td>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td class="left" style="width: 50%;"><?php if ($invoice_no) { ?>
          <b><?php echo $text_invoice_no; ?></b> <?php echo $invoice_no; ?><br />
          <?php } ?>
          <b><?php echo $text_order_id; ?></b> #<?php echo $order_id; ?><br />
          <b><?php echo $text_date_added; ?></b> <?php echo $date_added; ?></td>
      </tr>
    </tbody>
  </table>
  <table class="list">
    <thead>
      <tr>
          <td></td>
        <td class="left"><?php echo $column_name; ?></td>
          <td><?php echo $column_price; ?></td>
          <td style="width:22%"><?php echo $column_action; ?></td>
          <td style="width:15%"><?php echo $column_deploy_status; ?></td>
          <td><?php echo $column_description; ?></td>
      </tr>
    </thead>
    <tbody>
      <?php foreach ($products as $product) { ?>
      <tr>
          <td><a href="<?php echo $product['href'];?>" target="_blank"><img src="<?php echo $product['image'];?>" alt="<?php echo $product['name'];?>" /></a></td>
          <td><?php echo $product['name'];?></td>
          <td><?php echo $product['hour_price'];?><br/><?php echo $product['month_price'];?></td>
          <td>
              <div id="<?php echo $product['model'];?>_action">
                  <?php if($product['status']=='部署成功'){ ?>
                        <?php echo $product['action'];?>
                  <?php }else if($product['status']=='部署失败'){  ?>
                        <b style="color: #c91920;"><?php echo $product['error_text'];?></b>
                  <?php }else{  ?>
                        <?php echo $product['status'];?>
                  <?php } ?>
              </div>
          </td>
          <td>
              <?php if($product['status']=='部署成功'){ ?>
                        <div id="progressbar_<?php echo $product['model'];?>" class="ui-progressbar ui-widget ui-widget-content ui-corner-all" role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="100"><div class="progress-label progress-label_<?php echo $product['model'];?> ui-progressbar-overlay">完成</div><div class="ui-progressbar-value ui-widget-header ui-corner-left ui-corner-right" style="width: 100%;"></div></div>
              <?php }else if($product['status']=='部署失败'){  ?>
                        <?php echo $product['status'];?>
              <?php }else{  ?>
                        <div id="progressbar_<?php echo $product['model'];?>"><div class="progress-label progress-label_<?php echo $product['model'];?> ui-progressbar-overlay"><?php echo $this->language->get('order_status_finish');?></div></div>
              <?php } ?>

          </td>
          <td>
              <ul class="order_info_deploy">
            <?php foreach($product['deploy_info'] as  $deploy_info){ ?>
                  <?php if($deploy_info['name']!='系统管理员密码'){ ?>
                    <li><?php echo $deploy_info['name'];?>:<?php echo $deploy_info['value'];?></li>
                  <?php } ?>
              <?php } ?>
              </ul>
          </td>
      </tr>
      <?php } ?>
    </tbody>
    <tfoot>
      <?php foreach ($totals as $total) { ?>
      <tr>
        <td colspan="3"></td>
        <td class="right"><b><?php echo $total['title']; ?>:</b></td>
        <td class="right"><?php echo $total['text']; ?></td>
        <?php if ($products) { ?>
        <td></td>
        <?php } ?>
      </tr>
      <?php } ?>
    </tfoot>
  </table>
  <?php if ($comment) { ?>
  <table class="list">
    <thead>
      <tr>
        <td class="left"><?php echo $text_comment; ?></td>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td class="left"><?php echo $comment; ?></td>
      </tr>
    </tbody>
  </table>
  <?php } ?>

  <div class="buttons">
    <div class="right"><a href="<?php echo $continue; ?>" class="button"><?php echo $button_continue; ?></a></div>
  </div>

<script>
    $(function() {
        <?php foreach($products as $product ) { ?>
                <?php if(!$product['action']){ ?>
                                var progressbar_<?php echo $product['model'];?> = $( "#progressbar_<?php echo $product['model'];?>" ),
                                progressLabel_<?php echo $product['model'];?> = $( ".progress-label_<?php echo $product['model'];?>" );
                                progressbar_<?php echo $product['model'];?>.progressbar({
                                    value: <?php echo $product['proportion_value'];?>,
                                    change: function() {
                                        s_val=Math.round( progressbar_<?php echo $product['model'];?>.progressbar( "value")*100)/100;
                                    progressLabel_<?php echo $product['model'];?>.text( s_val + "%" );
                                },
                                complete: function() {
                                    progressLabel_<?php echo $product['model'];?>.text( "完成" );
                                }
                                });
                                function progress_<?php echo $product['model'];?>() {
                                    var val = progressbar_<?php echo $product['model'];?>.progressbar( "value" ) || 0;
                                    progressbar_<?php echo $product['model'];?>.progressbar( "value", val + <?php echo $product['base_time'];?> );
                                    if ( val < 98) {
                                        setTimeout( progress_<?php echo $product['model'];?>, 1000 );
                                    }
                                }
                                setTimeout( progress_<?php echo $product['model'];?>, 1000);
            <?php } ?>
        <?php } ?>
    });
</script>
    <script type="text/javascript">
        function chlink() {
            var url = "<?php echo $ajax_action;?>";
            $.post(url,{order_id:<?php echo $order_id;?>},function(json){
                var obj = JSON.parse(json);
                for(title in obj['result']){
                    if(obj['result'][title]['status']=='finished'){
                        progressbar = $( "#progressbar_"+obj['result'][title]['app_name']);
                        progressbar.progressbar( "value", 100);
                        $("#"+obj['result'][title]['app_name']+"_action").html(obj['result'][title]['action']);
                    }
                    if(obj['result'][title]['status']=='failed'){
                        progressbar = $( "#progressbar_"+obj['result'][title]['app_name']);
                        progressbar.progressbar( "value", 100);
                        progressbar.html('<span style="width: 100%; text-align: center; display: block; line-height: 2em;">部署失败</span>');
                    }
                }
            });
        }
        $(function() {
            timeID = setInterval('chlink()', 5000);  //注意:执行的函数需要加引号,否则会报错的
        });
    </script>


  <?php echo $content_bottom; ?></div>
<?php echo $footer; ?> 